- name: Inclure le configuration du backup
ansible.builtin.include_tasks: tasks/config_backup.yml
-# SFTP key
+ - name: Inclure le configuration SFTP
+ ansible.builtin.include_tasks: tasks/config_sftp.yml
+ when: sftp == 'oui'
--- /dev/null
+- name: Ajout de l'utilisateur site_SIGLE_SITE dans le group sftponly
+ ansible.builtin.user:
+ name: "site_{{ SIGLE }}_{{ SITE }}"
+ groups: sftponly
+ append: true
+
+# verif si le home appartient bien à root avec un mode 2750 ou 2770?
+
+- name: Boucle création ou modifications du repertoire .ssh
+ ansible.builtin.file:
+ path: "{{ item.path }}"
+ state: "{{ item.state }}"
+ owner: "{{ item.owner }}"
+ group: "{{ item.group }}"
+ mode: "{{ item.mode }}"
+ loop_control:
+ label: "{{ item.path }}"
+ loop:
+ - path: "/home/sites/data/{{ TLD }}/{{ DOMAIN }}/{{ SITE }}/.ssh"
+ state: directory
+ owner: "site_{{ SIGLE }}_{{ SITE }}"
+ group: "site_{{ SIGLE }}_{{ SITE }}"
+ mode: '2700'
+
+- name: Création du fichier authorized_keys
+ ansible.builtin.template:
+ src: "templates/authorized_keys.j2"
+ dest: "/home/sites/data/{{ TLD }}/{{ DOMAIN }}/{{ SITE }}/.ssh/authorized_keys"
+ owner: "site_{{ SIGLE }}_{{ SITE }}"
+ group: "site_{{ SIGLE }}_{{ SITE }}"
+ mode: '640'
+ when: sftp_key is defined
+
+# verif le serveur openssh est bien config et sinon le faire? + reload